{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import wave\n",
    "import numpy as np\n",
    "import array\n",
    "import struct\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "mic = pd.read_csv('mic.csv', header = None)\n",
    "data  = mic.values\n",
    "data=data[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-176 -258 -398 ... 2 4 2]\n"
     ]
    }
   ],
   "source": [
    "rate=8000\n",
    "pcmData16Bit=data[0:16000]\n",
    "print(pcmData16Bit)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "pcmData16Bit_f=pcmData16Bit.astype(np.float32)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "name=\"mic.wav\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def waveSetOut(outPath,pcmArray,pcmRate):\n",
    "    waveF=wave.open(outPath,\"wb\")\n",
    "    waveF.setnchannels(1)\n",
    "    waveF.setsampwidth(2)\n",
    "    waveF.setframerate(pcmRate)\n",
    "    for val in pcmArray:\n",
    "        val=round(float(val))\n",
    "        dataStruct =struct.pack(\"<h\",val)\n",
    "        waveF.writeframesraw(dataStruct)\n",
    "    waveF.writeframes(b\"\")\n",
    "    waveF.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "waveSetOut(name,pcmData16Bit_f,rate)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAD4CAYAAAAD6PrjAAAABHNC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vYrL2d6CQL9Dk2QdL+f//iLw2zr28ewcS9jBTbUfAr3zawl8yU51yu4jcAUO0BD4q/NHsgDo6XrtVOd1a4CxSYzpbeArYLHzM90pPxVY5vxRLANu8OF4PQSscGKYCxzreu31znEsBq5LZlzO83uAh2u8zrNjRuCq8UvgCIE22xuAm4Gbne0CPO3EvAwoStKxqi+uZ4G9rvNroVPe0zlOS5zf8dQkx3Wr69yahytphfr9JysuZ59rCQw8cb/O6+N1OoE+i6Wu39W4ZJ1jNs2FMcaYoEztUzDGGBMDSwrGGGOCLCkYY4wJsqRgjDEmyJKCMcaYIEsKxhhjgiwpGGOMCfr/efjsgguZI9sAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import wave\n",
    "import numpy as np\n",
    "import pylab as pl\n",
    "waveAbsPath=\"mic.wav\"\n",
    "f=wave.open(waveAbsPath,\"rb\")\n",
    "params=f.getparams()\n",
    "nchannels, sampwidth, framerate, nframes = params[:4]\n",
    "str_data = f.readframes(nframes)\n",
    "wave_data = np.frombuffer(str_data, \"int16\")\n",
    "wave_data.shape = -1, 2\n",
    "#将其转置得到：\n",
    "wave_data = wave_data.T\n",
    "#通过取样点数和取样频率计算出每个取样的时间：\n",
    "time = np.arange(0, nframes)/framerate\n",
    "pl.plot(time, wave_data.reshape((wave_data.shape[0] * wave_data.shape[1])))\n",
    "pl.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
